package sistemasdistribuidos;

import classesBase.Agendamento;
import classesBase.ModelaTabela;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import telasMensagem.Bloqueio;
import telasMensagem.SimNao;

public class IncluirAgendamento extends javax.swing.JDialog {

    static boolean fecha = false;
    static Agendamento ag = new Agendamento();
    SimpleDateFormat forma = new SimpleDateFormat("dd/MM/yyyy");
    SimpleDateFormat formata = new SimpleDateFormat("yyyy-MM-dd");
    static ModelaTabela mo = new ModelaTabela();

    public IncluirAgendamento(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public IncluirAgendamento(java.awt.Frame parent, boolean modal,
            Date data, String hora, String banhista) {
        super(parent, modal);
        initComponents();
        jTextFieldCodigoAgenda.setEnabled(false);
        jTextFieldCodigoAgenda.setText("00001");
        jLabelBanhista.setText(banhista);
        jTextFieldCodigoDono.setEditable(false);
        /*
         fazer busca para encontrar o profissional no banco, 
         setar o ID na classe
         ag.setProfissional(Resultado da busca);
         */
        ag.setCodAgendamento(0005);
        ag.setCodAgendamento(Integer.parseInt(jTextFieldCodigoAgenda.getText()));
        ag.setHorário(hora);
        ag.setDia(formata.format(data));
        jLabelData.setText(forma.format(data));
        jLabelHorario.setText(hora);
        jTextFieldAnimal.setEditable(false);
        jTextFieldCodigoAnimal.setEditable(false);
        jTextFieldDono.setEditable(false);
        tabela();

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja "
                        + "sair sem salvar o agendamento? Todos os dados inseridos "
                        + "serão perdidos!<html>", 2);
                sn.setLocationRelativeTo(null);
                sn.setVisible(true);
                if (fecha == true) {
                    dispose();
                }
            }
        }
        );
    }

    public void tabela() {
        mo = new ModelaTabela();
        mo.setColumnIdentifiers(new String[]{"Código", "Descrição", "Quant.", "Preço Un", "Total"});
        mo.setColumnEditable(true, 2);
        jTableServiços.setRowHeight(20);
        jTableServiços.setModel(mo);
        jTableServiços.getColumnModel().getColumn(2).setPreferredWidth(15);
        jTableServiços.getColumnModel().getColumn(3).setPreferredWidth(25);
        jTableServiços.getColumnModel().getColumn(4).setPreferredWidth(25);
        jTableServiços.getColumnModel().getColumn(0).setPreferredWidth(25);
    }

    public static void selecionarAnimal(String codigoA, String animal, String dono, int codDono) {
        jTextFieldAnimal.setText(animal);
        jTextFieldCodigoAnimal.setText(codigoA);
        jTextFieldDono.setText(dono);
        jTextFieldCodigoDono.setText(String.valueOf(codDono));
    }

    public static void addServicos(String cod, String descricao, String un) {
        mo.addRow(new String[]{cod, descricao, "1", un, un});
    }

    public static void fechar(boolean t) {
        fecha = t;
    }

    public void blo(String me) {
        Bloqueio b = new Bloqueio(null, true, me);
        b.setLocationRelativeTo(null);
        b.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelMsg10 = new javax.swing.JLabel();
        jLabelMsg14 = new javax.swing.JLabel();
        jButtonSalvarCadastroAgenda = new javax.swing.JButton();
        jButtonLimparDados = new javax.swing.JButton();
        jLabelMsg12 = new javax.swing.JLabel();
        jLabelMsg13 = new javax.swing.JLabel();
        jLabelMsg16 = new javax.swing.JLabel();
        jLabelMsg17 = new javax.swing.JLabel();
        jTextFieldAnimal = new javax.swing.JTextField();
        jTextFieldDono = new javax.swing.JTextField();
        jLabelMsg19 = new javax.swing.JLabel();
        jTextFieldCodigoAgenda = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTableServiços = new javax.swing.JTable();
        jLabelMsg20 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextPaneObservacoes = new javax.swing.JTextPane();
        jLabelBanhista = new javax.swing.JLabel();
        jLabelData = new javax.swing.JLabel();
        jButtonBuscar = new javax.swing.JButton();
        jLabelMsg21 = new javax.swing.JLabel();
        jTextFieldCodigoServico = new javax.swing.JTextField();
        jButtonBuscar2 = new javax.swing.JButton();
        jLabelHorario = new javax.swing.JLabel();
        jLabelMsg18 = new javax.swing.JLabel();
        jTextFieldCodigoAnimal = new javax.swing.JTextField();
        jLabelMsg22 = new javax.swing.JLabel();
        jButtonBuscar3 = new javax.swing.JButton();
        jTextFieldCodigoDono = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Incluir Agendamento ");
        setAutoRequestFocus(false);
        setModal(true);

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg10.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg10.setText("Data:");

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Incluir Novo Agendamento");

        jButtonSalvarCadastroAgenda.setBackground(new java.awt.Color(255, 255, 255));
        jButtonSalvarCadastroAgenda.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonSalvarCadastroAgenda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonSalvarCadastroAgenda.setText("Salvar");
        jButtonSalvarCadastroAgenda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonSalvarCadastroAgenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarCadastroAgendaActionPerformed(evt);
            }
        });

        jButtonLimparDados.setBackground(new java.awt.Color(255, 255, 255));
        jButtonLimparDados.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonLimparDados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/osso.png"))); // NOI18N
        jButtonLimparDados.setText("Cancelar");
        jButtonLimparDados.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonLimparDados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimparDadosActionPerformed(evt);
            }
        });

        jLabelMsg12.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg12.setText("Profissional:");

        jLabelMsg13.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg13.setText("Horário:");

        jLabelMsg16.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg16.setText("Animal:");
        jLabelMsg16.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg16jLabelMsg17MouseClicked(evt);
            }
        });

        jLabelMsg17.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg17.setText("Dono:");
        jLabelMsg17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg17MouseClicked(evt);
            }
        });

        jTextFieldAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAnimalActionPerformed(evt);
            }
        });

        jTextFieldDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldDonoActionPerformed(evt);
            }
        });

        jLabelMsg19.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg19.setText("Código:");

        jTextFieldCodigoAgenda.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoAgenda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoAgendaActionPerformed(evt);
            }
        });

        jTableServiços.setBorder(javax.swing.BorderFactory.createMatteBorder(2, 2, 2, 2, new java.awt.Color(0, 0, 0)));
        jTableServiços.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jTableServiços.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Descrição", "Quantidade", "Preço Un", "Valor Total"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableServiços.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentRemoved(java.awt.event.ContainerEvent evt) {
                jTableServiçosComponentRemoved(evt);
            }
        });
        jScrollPane4.setViewportView(jTableServiços);

        jLabelMsg20.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg20.setText("Observações:");

        jTextPaneObservacoes.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jScrollPane6.setViewportView(jTextPaneObservacoes);

        jLabelBanhista.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelBanhista.setText("Banhista");

        jLabelData.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelData.setText("22/22/2222");

        jButtonBuscar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscar.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        jLabelMsg21.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg21.setText("Adicionar Serviços ao Banho:");

        jTextFieldCodigoServico.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoServico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoServicoActionPerformed(evt);
            }
        });
        jTextFieldCodigoServico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldCodigoServicoKeyPressed(evt);
            }
        });

        jButtonBuscar2.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscar2.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscar2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscar2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscar2ActionPerformed(evt);
            }
        });

        jLabelHorario.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelHorario.setText("Horário:");

        jLabelMsg18.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/banhos.png"))); // NOI18N

        jTextFieldCodigoAnimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoAnimal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoAnimalActionPerformed(evt);
            }
        });

        jLabelMsg22.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg22.setText("Código do Animal:");

        jButtonBuscar3.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscar3.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscar3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/x.png"))); // NOI18N
        jButtonBuscar3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscar3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscar3ActionPerformed(evt);
            }
        });

        jTextFieldCodigoDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoDonoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(178, 178, 178)
                        .addComponent(jLabelMsg14))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(165, 165, 165)
                                        .addComponent(jButtonSalvarCadastroAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabelMsg22)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldCodigoAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(44, 44, 44)
                                .addComponent(jButtonLimparDados, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabelMsg12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabelBanhista))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabelMsg21)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jTextFieldCodigoServico, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(87, 87, 87))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabelMsg16)
                                                    .addComponent(jLabelMsg17))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(jTextFieldCodigoDono)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                                        .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                        .addGap(14, 14, 14))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabelMsg20)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addGap(344, 344, 344)
                                                    .addComponent(jButtonBuscar2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jButtonBuscar3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelMsg18, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabelMsg10)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabelData, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabelMsg13)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jLabelHorario))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jLabelMsg19)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jTextFieldCodigoAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(44, 44, 44)))))))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonLimparDados, jButtonSalvarCadastroAgenda});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg12)
                    .addComponent(jLabelBanhista))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg22)
                            .addComponent(jTextFieldCodigoAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jLabelMsg16))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg17)
                            .addComponent(jTextFieldCodigoDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg19)
                            .addComponent(jTextFieldCodigoAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelHorario)
                            .addComponent(jLabelMsg13))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg10)
                            .addComponent(jLabelData))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelMsg18, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTextFieldCodigoServico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabelMsg21)))
                            .addComponent(jButtonBuscar2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonBuscar3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelMsg20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(32, 32, 32)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSalvarCadastroAgenda, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonLimparDados, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonLimparDados, jButtonSalvarCadastroAgenda});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonSalvarCadastroAgendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarCadastroAgendaActionPerformed
        try {
            ag.setCodAnimal(Integer.parseInt(jTextFieldCodigoAnimal.getText()));
            ag.setCodDono(Integer.parseInt(jTextFieldCodigoDono.getText()));
            ag.setObs(jTextPaneObservacoes.getText());
            if (jTableServiços.getRowCount() > 0) {
                /*
                 Salvar no banco
                 */
                System.out.println(ag.getCodAgendamento() + "\n" + ag.getCodAnimal()
                        + "\n" + ag.getCodDono() + "\n" + ag.getDia() + "\n" + ag.getHorário()
                        + "\n" + ag.getProfissional() + "\n" + ag.getObs());
            } else {
                blo("<html>Nenhum serviço foi adicionado!<br> "
                        + "Por favor, selecione no mínimo um serviço no agendamento "
                        + "antes de prosseguir!");
            }
        } catch (Exception ex) {
            blo("<html>Você deixou de preencher alguma informação!<br> "
                    + "Por favor, verifique as informações do agendamento "
                    + "antes de prosseguir!");
        }
    }//GEN-LAST:event_jButtonSalvarCadastroAgendaActionPerformed

    private void jButtonLimparDadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimparDadosActionPerformed
        SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja cancelar o"
                + " agendamento? <br> "
                + "Todas as informações inseridas nesta tela serão"
                + " perdidas! ", 12);
        sn.setLocationRelativeTo(null);
        sn.setVisible(true);
        if (fecha == true) {
            this.dispose();
        }
    }//GEN-LAST:event_jButtonLimparDadosActionPerformed

    private void jLabelMsg16jLabelMsg17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg16jLabelMsg17MouseClicked

    }//GEN-LAST:event_jLabelMsg16jLabelMsg17MouseClicked

    private void jLabelMsg17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg17MouseClicked

    }//GEN-LAST:event_jLabelMsg17MouseClicked

    private void jTextFieldAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldAnimalActionPerformed

    }//GEN-LAST:event_jTextFieldAnimalActionPerformed

    private void jTextFieldDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldDonoActionPerformed

    }//GEN-LAST:event_jTextFieldDonoActionPerformed

    private void jTextFieldCodigoAgendaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoAgendaActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoAgendaActionPerformed

    private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed
        try {
            AnimaisCadastrados a = new AnimaisCadastrados(null, true, 3);
            a.setLocationRelativeTo(null);
            a.setVisible(true);
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonBuscarActionPerformed

    private void jTextFieldCodigoServicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoServicoActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoServicoActionPerformed

    private void jButtonBuscar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscar2ActionPerformed
        ServicosCadastrados s = new ServicosCadastrados(null, true, 1);
        s.setLocationRelativeTo(null);
        s.setVisible(true);
    }//GEN-LAST:event_jButtonBuscar2ActionPerformed

    private void jTextFieldCodigoAnimalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoAnimalActionPerformed

    }//GEN-LAST:event_jTextFieldCodigoAnimalActionPerformed

    private void jTextFieldCodigoServicoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCodigoServicoKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            //colocar if para verificar se o código está cadastrado
            mo.addRow(new String[]{"123", "efknsl", "1", "12"});
            jTextFieldCodigoServico.setText("");
        }
    }//GEN-LAST:event_jTextFieldCodigoServicoKeyPressed

    private void jTableServiçosComponentRemoved(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jTableServiçosComponentRemoved
        double quan = Double.parseDouble((String) jTableServiços.getValueAt(jTableServiços.getSelectedRow(), 2));
        double valor = Double.parseDouble((String) jTableServiços.getValueAt(jTableServiços.getSelectedRow(), 3));

        valor = quan * valor;

        mo.setValueAt(valor, jTableServiços.getSelectedRow(), 4);
    }//GEN-LAST:event_jTableServiçosComponentRemoved

    private void jButtonBuscar3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscar3ActionPerformed
        try {
            mo.removeRow(jTableServiços.getSelectedRow());
        } catch (Exception ex) {
            blo("<html>Nenhum serviço foi selecionado!<br> "
                    + "Por favor, selecione na tabela o serviço "
                    + "que deseja deletar!");
            System.out.println(ex);
        }
    }//GEN-LAST:event_jButtonBuscar3ActionPerformed

    private void jTextFieldCodigoDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoDonoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldCodigoDonoActionPerformed

    public static void main(String args[]) {

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IncluirAgendamento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IncluirAgendamento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IncluirAgendamento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IncluirAgendamento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                IncluirAgendamento dialog = new IncluirAgendamento(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonBuscar2;
    private javax.swing.JButton jButtonBuscar3;
    private javax.swing.JButton jButtonLimparDados;
    private javax.swing.JButton jButtonSalvarCadastroAgenda;
    private javax.swing.JLabel jLabelBanhista;
    private javax.swing.JLabel jLabelData;
    private javax.swing.JLabel jLabelHorario;
    private javax.swing.JLabel jLabelMsg10;
    private javax.swing.JLabel jLabelMsg12;
    private javax.swing.JLabel jLabelMsg13;
    private javax.swing.JLabel jLabelMsg14;
    private javax.swing.JLabel jLabelMsg16;
    private javax.swing.JLabel jLabelMsg17;
    private javax.swing.JLabel jLabelMsg18;
    private javax.swing.JLabel jLabelMsg19;
    private javax.swing.JLabel jLabelMsg20;
    private javax.swing.JLabel jLabelMsg21;
    private javax.swing.JLabel jLabelMsg22;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTable jTableServiços;
    public static javax.swing.JTextField jTextFieldAnimal;
    public static javax.swing.JTextField jTextFieldCodigoAgenda;
    public static javax.swing.JTextField jTextFieldCodigoAnimal;
    public static javax.swing.JTextField jTextFieldCodigoDono;
    public static javax.swing.JTextField jTextFieldCodigoServico;
    public static javax.swing.JTextField jTextFieldDono;
    public static javax.swing.JTextPane jTextPaneObservacoes;
    // End of variables declaration//GEN-END:variables
}
